package com.eshore.common.service.impl;

import com.eshore.khala.core.starter.common.Result;
import com.eshore.workflow.service.TaskInstanceIdentity;
import com.eshore.workflow.service.WorkflowService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * @author 李仲允
 * @date 2022/5/5 08:38
 */
public class WorkflowServiceMockImpl implements WorkflowService {

    private static final Logger log = LoggerFactory.getLogger(WorkflowServiceMockImpl.class);

    @Override
    public Result<Boolean> activateProcessInstance(String processInstanceId) {
        log.info("[Workflow]流程激活, procInstId={}", processInstanceId);
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<Boolean> backToStart(String processInstanceId, String taskInstanceId, Map<String, Object> extraParams) {
        log.info("[Workflow]任务回退拟稿, procInstId={}, taskInstId={}, params={}",
                processInstanceId, taskInstanceId, extraParams);
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<Boolean> backToPreviousStep(String processInstanceId, String taskInstanceId) {
        log.info("[Workflow]");
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<Boolean> cancelProcess(String processInstanceId, Map<String, Object> extraParams) {
        log.info("[Workflow]");
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<String> completeTask(String taskInstanceId, Map<String, Object> extraParams) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public Result<String> completeTask(String taskInstanceId, String nextUserTaskId, String nextTaskUserId, Map<String, Object> extraParams) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public Result<String> endProcess(String processInstanceId) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public Result<Boolean> recycleTask(String processInstanceId, String taskInstanceId, Map<String, Object> extraParams) {
        log.info("[Workflow]");
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<Boolean> startProcess(String processDefinitionKey, String userId, Map<String, Object> extraParams) {
        log.info("[Workflow]");
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<Boolean> startProcess(String processDefinitionKey, String userId, String businessKey, Map<String, Object> extraParams) {
        log.info("[Workflow]");
        return Result.success(Boolean.TRUE);
    }

    @Override
    public Result<String> claim(String taskInstanceId, String claimerUserId) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public Result<String> sendBack(String taskInstanceId) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public Result<String> suspend(String processInstanceId) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public Result<String> transferTask(String taskInstanceId, String userId) {
        log.info("[Workflow]");
        return Result.success("SUCCESS");
    }

    @Override
    public String findTaskInstanceId(String processInstanceId, String userTaskId) {
        log.info("[Workflow]");
        return "TII-002";
    }

    @Override
    public String findProcessInstanceId(String taskInstanceId) {
        log.info("[Workflow]");
        return "PII-001";
    }

    @Override
    public TaskInstanceIdentity findTaskInstanceIdentity(String processInstanceId, String userTaskId) {
        return new TaskInstanceIdentity("PDK-001", processInstanceId, "TDK-001", "TII-002");
    }

    @Override
    public TaskInstanceIdentity findTaskInstanceIdentity(String taskInstanceId) {
        return new TaskInstanceIdentity("PDK-001", "PII-002", "TDK-001", taskInstanceId);
    }

    @Override
    public TaskInstanceIdentity findTaskInstanceIdentity(String processDefinitionKey, String userTaskId, String bizKey, String userId) {
        return new TaskInstanceIdentity(processDefinitionKey, "PII-003", userTaskId, "TII-004");
    }
}
